package io.gitee.cisumer.amazing.master;

import io.gitee.cisumer.amazing.Pixel;

/**
 * 银河漫游
 * @author gitee.com/cisumer
 * @date create in 2022/3/17
 */
public class MandelbrotGalaxy implements Pixel {
	@Override
	public int r(int i, int j) {
		double a=0,b=0,c,d,n=0;
		while((c=a*a)+(d=b*b)<4&&n++<880)
		{b=2*a*b+j*8e-9-.645411;a=c-d+i*8e-9+.356888;}
		return (int) (255*Math.pow((n-80)/800,3.));
	}
	
	@Override
	public int g(int i, int j) {
		double a=0,b=0,c,d,n=0;
		while((c=a*a)+(d=b*b)<4&&n++<880)
		{b=2*a*b+j*8e-9-.645411;a=c-d+i*8e-9+.356888;}
		return (int) (255*Math.pow((n-80)/800,.7));
	}
	
	@Override
	public int b(int i, int j) {
		double a=0,b=0,c,d,n=0;
		while((c=a*a)+(d=b*b)<4&&n++<880)
		{b=2*a*b+j*8e-9-.645411;a=c-d+i*8e-9+.356888;}
		return (int) (255*Math.pow((n-80)/800,.5));
	}
	
	@Override
	public String name() {
		return "银河";
	}
}
